/**
 * *****************************************
 * Project: cone
 * File: ResourceHandler.java
 * Creation Date: 12:17:08 PM
 * Creator: Ahmed Fawzy
 * *****************************************
 * Copyright © 2012 Devariance.
 */
package com.devariance.cone.handler;

import java.util.List;

import javax.naming.OperationNotSupportedException;
import javax.ws.rs.core.MultivaluedMap;

import com.devariance.cone.handler.exception.InternalResourceHandlerException;
import com.devariance.cone.handler.exception.InvalidResourceException;
import com.devariance.cone.handler.exception.ResourceCannotBeAcceptedException;
import com.devariance.cone.handler.exception.ResourceCannotBeUpdatedException;
import com.devariance.cone.handler.exception.ResourceNotFoundException;
import com.devariance.cone.resource.Resource;

/**
 * @author Ahmed Fawzy
 * @param <R>
 */
public interface ResourceHandler<R extends Resource> {

	/**
	 * @return
	 */
	R createResource();

	/**
	 * @param resourceParams
	 * @return
	 */
	R createResource(MultivaluedMap<String, String> resourceParams);

	/**
	 * @param id
	 * @throws InvalidResourceException
	 * @throws ResourceNotFoundException
	 * @throws ResourceCannotBeUpdatedException
	 * @throws OperationNotSupportedException
	 * @throws InternalResourceHandlerException
	 */
	void delete(Long id) throws InvalidResourceException,
			ResourceNotFoundException, ResourceCannotBeUpdatedException,
			OperationNotSupportedException, InternalResourceHandlerException;

	/**
	 * @param identifier
	 * @return
	 * @throws ResourceNotFoundException
	 * @throws OperationNotSupportedException
	 * @throws InternalResourceHandlerException
	 */
	Resource get(Long identifier) throws ResourceNotFoundException,
			OperationNotSupportedException, InternalResourceHandlerException;

	/**
	 * @param index
	 * @param count
	 * @return
	 * @throws OperationNotSupportedException
	 * @throws InternalResourceHandlerException
	 */
	List<? extends Resource> get(Long index, Long count)
			throws OperationNotSupportedException,
			InternalResourceHandlerException;

	/**
	 * @return
	 * 
	 */
	String getOptions();

	/**
	 * @param resource
	 * @return
	 * @throws InvalidResourceException
	 * @throws ResourceNotFoundException
	 * @throws ResourceCannotBeAcceptedException
	 * @throws OperationNotSupportedException
	 * @throws InternalResourceHandlerException
	 */
	Long post(Resource resource) throws InvalidResourceException,
			ResourceNotFoundException, ResourceCannotBeAcceptedException,
			OperationNotSupportedException, InternalResourceHandlerException;

	/**
	 * @param identifier
	 * @param resource
	 * @throws InvalidResourceException
	 * @throws ResourceNotFoundException
	 * @throws ResourceCannotBeUpdatedException
	 * @throws OperationNotSupportedException
	 * @throws InternalResourceHandlerException
	 */
	void put(Resource resource) throws InvalidResourceException,
			ResourceNotFoundException, ResourceCannotBeUpdatedException,
			OperationNotSupportedException, InternalResourceHandlerException;
}
